package com.drug.service.impl;

import com.drug.domain.DrugCategory;
import com.drug.domain.Result;
import com.drug.mapper.DrugCategoryMapper;
import com.drug.service.DrugCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DrugCategoryServiceImpl implements DrugCategoryService {

    @Autowired
    private DrugCategoryMapper drugCategoryMapper;

    /**
     * 查询全部类别
     * @return
     */
    @Override
    public Result fandAllDrugCategory() {
        List list = drugCategoryMapper.selectAll();
        Result result = new Result();
        result.setData(list);
        return result;
    }

    /**
     * 根据药品名称查询id
     * @param name
     * @return
     */
    @Override
    public Result selectIdbyName(String name) {
        int i = drugCategoryMapper.selectIdbyName(name);
        Result result = new Result();
        result.setCode(i);
        return result;
    }

    /**
     * 根据id查询药品类别
     * @param dcId
     * @return
     */
    @Override
    public Result findByPrimaryKey(Integer dcId) {
        Result result = new Result();
        DrugCategory drugCategory = drugCategoryMapper.selectByPrimaryKey(dcId);
        result.setData(drugCategory);
        return result;
    }
}
